<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use app\models\MAbout;
use app\models\MGoodscat;
use app\models\MGoods;
use app\models\Category;




AppAsset::register($this);

$about = MAbout::find()->one();
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">

    <!--
    <meta name="viewport" content="width=device-width, initial-scale=1">
    -->

    <!-- Sets initial viewport load and disables zooming  -->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">

    <!-- Makes your prototype chrome-less once bookmarked to your phone's home screen -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">


    <!--
    <LINK href="favicon1.ico" type="image/x-icon" rel=icon>
    <LINK href="favicon1.ico" type="image/x-icon" rel="shortcut icon">
    -->
    <link rel="stylesheet" href="http://libs.useso.com/js/font-awesome/4.2.0/css/font-awesome.min.css">
    <?= Html::csrfMetaTags() ?>
    <title><?= empty($about->com_name)?"首页":$about->com_name ?></title>
    <?php $this->head() ?>
    
    <style type="text/css">
        .input-group {
            margin-top: -15px;
        }

        /* 回到顶部开始 */
        .back-to-top { position: fixed; bottom: 100px; right: 2px; padding: 3px 8px; font-size: 24px; color: #666; display: none; }
        /* 回到顶部结束 */
    </style>


    <style type="text/css">
        /* 自定义顶部菜单风格； 蓝色风格 */
        .navbar-inverse {
            background-color: #0593d3;
            border-color: #0593d3;
        }
        .navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
            color: #fff;
            background-color: #0482ba;
        }

        .navbar-inverse .navbar-nav > li > a {
            color: #fff;
        }

        .navbar-inverse .navbar-brand {
            color: #fff;
        }

        .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus {
        color: #fff;
        background-color: #0482ba;
        }

        .navbar-inverse .navbar-toggle {
            border-color: #0482ba;
     
        }

        .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus {
                  background-color: #0482ba;
        }

        .navbar-collapse, .navbar-inverse .navbar-form {
            border-color: #0482ba;
        }

        .navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
            border-color: #0482ba;
        }

        .footer {
            height: 60px;
            background-color: #f5f5f5;
            border-top: 1px solid #ddd;
            padding-top: 20px;
        }

        .badge1 {
            display: inline-block;
            min-width: 10px;
            padding: 3px 7px;
            font-size: 12px;
            font-weight: bold;
            line-height: 1;
            color: #fff;
            text-align: center;
            white-space: nowrap;
            vertical-align: middle;
            background-color: #e0e0e0;
            border-radius: 10px;
        }
        /*
        .wrap {
            min-height: 100%;
            height: auto;
            margin: 0 auto -60px;
            padding: 0 0 0;
        }
        */
    </style>

    <style type="text/css">
       /*
        *{padding:0;margin:0;}
 
        ul,ol{list-style:none;}
        img{border:none;outline:none;}
        */
        a{color:#666;text-decoration:none;outline:none;}
        /*
        a:hover{color:#e8431f;}
        */

        /*浮动客服*/
        #floatDivBoxs{width:170px;background:#fff;position:fixed;top:100px;right:-170px;z-index:999;}
        #floatDivBoxs .floatDtt{width:100%;height:34px;line-height:45px; background:#0593d3;color:#fff;font-size:18px;text-indent:22px;position:relative;}
        #floatDivBoxs .floatDqq{padding:0 14px;}
        #floatDivBoxs .floatDqq li{height:45px;line-height:45px;font-size:15px;border-bottom:1px solid #e3e3e3; text-align:right}
        #floatDivBoxs .floatDqq li img{ float:left; margin-top:7px;}
        #floatDivBoxs .floatDtxt{font-size:18px;color:#333;padding:12px 14px;}
        #floatDivBoxs .floatDtel{padding:0 0 15px 10px;}
        #floatDivBoxs .floatImg{text-align:center;padding:10px;background:#EBEBEB;}
        #floatDivBoxs .floatImg img{ margin-bottom:5px;}
        #floatDivBoxs .floatDtel img{display:block;}

        .floatShadow{ background:#fff;box-shadow:-2px 0 3px rgba(0,0,0,0.25);}
        #rightArrow{width:45px;height:160px;background:url(../images/online_arrow1.jpg) no-repeat;position:fixed;top:100px;right:0;z-index:999;}
        #rightArrow a{display:block;height:160px;}
    </style>

</head>
<body>
<?php $this->beginBody() ?>

<div class="wrap">

        <?php
        if(Yii::$app->user->isGuest)
        {
            $isAdmin = false;
            $isMember = false;
        }
        else
        { 
            if (Yii::$app->user->identity->role == 1)
            {
                $isAdmin = true;
                $isMember = false;
                $flagLable = "&nbsp;<span style='font-size:14px; background:#0482ba; border:solid 1px #fff;-webkit-border-radius: 10px;border-radius: 10px;'>&nbsp;管理后台&nbsp;</span>";
            }
            else /*role == 0*/
            {
                $isAdmin = false;
                $isMember = true;
                $flagLable = "";
            }
        }

        //get goods cat
        //$goodscat = MGoodscat::find()->all();
        $goodscat = Category::find()->where(['parent_id' => 0])->all();

        $brandLabel = empty($about->com_name)?"":$about->com_name;
        $brandLabel = $brandLabel.$flagLable;
        NavBar::begin([
             //'brandLabel' => Html::img($asset->baseUrl . '/logo.png'),
            'brandLabel' => $brandLabel,
            'brandUrl' => Yii::$app->homeUrl,
            'options' => [
                'class' => 'navbar-inverse navbar-fixed-top',
            ],

        ]);
        /*
        $menuItems = [
            ['label' => '首页', 'url' => ['/site/index']],
            ['label' => '关于', 'url' => ['/site/about']],
            ['label' => '联系', 'url' => ['/site/contact']],
        ];

            if (Yii::$app->user->isGuest) {
                $menuItems[] = ['label' => '注册', 'url' => ['/site/signup']];
                $menuItems[] = ['label' => '登录', 'url' => ['/site/login']];
            } else {

            //if (Yii::$app->user->identity->role == 1) {
                $menuItems[] = [
                    'label' => '商品',
                    'url' => ['/goods/index','pub_userid'=>Yii::$app->user->identity->id],
                    'linkOptions' => ['data-method' => 'post']
                ];
            //}

            $menuItems[] = [
                'label' => '退出 (' . Yii::$app->user->identity->username . ')',
                'url' => ['/site/logout'],
                'linkOptions' => ['data-method' => 'post']
            ];
        }
        */

        foreach ($goodscat as $gc) {

            $goodsCnt = MGoods::find()->where(['status' => 1, 'goods_kind' => $gc->id])->count();

            if($goodsCnt == 0)
            {
                $menuItems[] = [
                    'label' => $gc->name.'&nbsp;<span>&nbsp;</span> ',
                    'url' => ['/site/client-goods-list','pub_userid'=>Yii::$app->user->isGuest?-1:Yii::$app->user->identity->id,'goods_kind'=>$gc->id],
                    'linkOptions' => ['data-method' => 'post']
                ];
            }
            else
            {
                $menuItems[] = [
                    'label' => $gc->name.'&nbsp;<span class="badge1">'.$goodsCnt.'</span> ',
                    'url' => ['/site/client-goods-list','pub_userid'=>Yii::$app->user->isGuest?-1:Yii::$app->user->identity->id,'goods_kind'=>$gc->id],
                    'linkOptions' => ['data-method' => 'post']
                ];
            }

        }

      
        echo Nav::widget([
            'options' => ['class' => 'navbar-nav navbar-right'],
            'encodeLabels' => false,
            //'items' => $menuItems,
            'items' => [

                //['label' => '<form class="navbar-form navbar-left" role="search"><div class="input-group"><input type="text" class="form-control" placeholder="Search"><span class="input-group-btn"><button class="btn btn-default" type="button"><span class="fa fa-search"></span></button></span></div></form>'],

                ['label' => '首页', 'url' => ['/site/index']],

                //['label' => '关于', 'url' => ['/site/about']],
                ($isAdmin)?"":
                [
                    'label' => '关于我们',
                    'items' => [
                        ['label' => '公司简介','url' => ['/site/about'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '招贤纳士','url' => ['/site/client-hr-list','cat'=>7],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '意见反馈','url' => ['/site/contact'],'linkOptions' => ['data-method' => 'post']],
                    ]
                ],

                ($isAdmin)?"":
                [
                    'label' => '技术天地',
                    'items' => [
                        ['label' => '解决方案','url' => ['/site/client-tech-list','cat'=>4],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '产品学习','url' => ['/site/client-tech-list','cat'=>5],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '技术文章','url' => ['/site/client-tech-list','cat'=>6],'linkOptions' => ['data-method' => 'post']],
                    ]
                ],


                //['label' => '联系', 'url' => ['/site/contact']],
                //['label' => '商品列表', 'url' => ['/site/client-goods-list']],

                ($isAdmin)?"":
                [
                    'label' => '商品列表',
                    'items' => $menuItems,
                ],


                ($isAdmin)?"":
                [
                    'label' => '新闻动态',
                    'items' => [
                        ['label' => '行业新闻','url' => ['/site/client-news-list','cat'=>1],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '公司动态','url' => ['/site/client-news-list','cat'=>2],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '展会信息','url' => ['/site/client-news-list','cat'=>3],'linkOptions' => ['data-method' => 'post']],
                    ]
                ], 


                [
                    'label' => '会员',
                    'visible' => $isMember,
                    'items' => [
                        ['label' => '<i class="fa fa-tags"></i> 商品管理','url' => ['/goods/index','pub_userid'=>Yii::$app->user->identity->id, 'goods_kind' => 0],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-shopping-cart"></i> 我的订单','url' => ['/order/index','userid'=>Yii::$app->user->identity->id],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-user"></i> 会员信息','url' => ['/site/client-user-view','id'=>Yii::$app->user->identity->id],'linkOptions' => ['data-method' => 'post']],

                    ]
                ],   

                [
                    'label' => '管理',
                    'visible' => $isAdmin,
                    'items' => [
                        ['label' => '<i class="fa fa-user"></i> 用户管理','url' => ['/user/index'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-tags"></i> 商品管理','url' => ['/goods/index','pub_userid'=>Yii::$app->user->identity->id, 'goods_kind' => 0],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-shopping-cart"></i> 订单管理','url' => ['/order/index','userid'=>Yii::$app->user->identity->id],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-reorder"></i> 商品分类管理','url' => ['/category/index'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-reorder"></i> 商品品牌管理','url' => ['/brand/index'],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-newspaper-o"></i> 文章管理','url' => ['/news/index', 'cat' => 0],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-sitemap"></i> 公司信息设置','url' => ['/about/index'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-cog"></i> 网站全局配置','url' => ['/keywords/index'],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-envelope"></i> 用户反馈','url' => ['/suggest/index'],'linkOptions' => ['data-method' => 'post']],

                    ]
                ],      

                Yii::$app->user->isGuest?
                ['label' => '登录', 'url' => ['/site/login']]:
                [
                    'label' => '<span class="glyphicon glyphicon-user"></span> '.Html::encode(Yii::$app->user->identity->username),
                    'items' => [
                        //['label' => '修改设置','url' => ['/site/profile'],'linkOptions' => ['data-method' => 'post']],
                        //'<li class="divider"></li>',
                        ['label' => '<i class="fa  fa-sign-out"></i> 退出','url' => ['/site/logout'],'linkOptions' => ['data-method' => 'post']],
                    ]
                ],

            ],
        ]);
        NavBar::end();
    ?>


    <div class="container">
        <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?>
        <?= $content ?>
    </div>

     <a class="back-to-top btn btn-default"><span class="fa fa-arrow-up"></span></a>
</div>

<footer class="footer">
    <div class="container">

        <p align="center">
            <span class="glyphicon glyphicon-globe"></span>
            <?= empty($about->com_name)?"":$about->com_name ?>&copy; <?= date('Y') ?>

            <a href="map.php">导航</a>

            <br>
            <span class="glyphicon glyphicon-home"></span>
            <?= empty($about->com_addr)?"":$about->com_addr ?>
          
            &nbsp;&nbsp;
            <span class="glyphicon glyphicon-earphone"></span>
            <a href="tel:<?= empty($about->com_tel)?'':$about->com_tel ?>">
            <?= empty($about->com_tel)?"":$about->com_tel ?>
            </a>
        </p>
		<!--
        <p class="pull-right"><//?= Yii::powered() ?></p>
		-->

    </div>
</footer>

<!-- 代码部分begin -->
<?php

    $rxdh = \app\models\Keywords::findOne(['key'=>'rxdh']);
    $rxdh = $rxdh->value;

    $kefu_qq_1 = \app\models\Keywords::findOne(['key'=>'kefu_qq_1']);
    $kefu_qq_1 = $kefu_qq_1->value;

    $kefu_qq_2 = \app\models\Keywords::findOne(['key'=>'kefu_qq_2']);
    $kefu_qq_2 = $kefu_qq_2->value;

    $kefu_qq_3 = \app\models\Keywords::findOne(['key'=>'kefu_qq_3']);
    $kefu_qq_3 = $kefu_qq_3->value;

    if($kefu_qq_1 == '0')
        $qq_icon_1 = "/images/qq_offline.png";
    else
        $qq_icon_1 = "/images/qq.png";

    if($kefu_qq_2 == '0')
        $qq_icon_2 = "/images/qq_offline.png";
    else
        $qq_icon_2 = "/images/qq.png";

    if($kefu_qq_3 == '0')
        $qq_icon_3 = "/images/qq_offline.png";
    else
        $qq_icon_3 = "/images/qq.png";


?>
<div id="rightArrow"><a href="javascript:;" title="在线客户"></a></div>
<div id="floatDivBoxs">

  <div class="floatShadow">
    <ul class="floatDqq">
      <li><a target="_blank" href="tencent://message/?uin=<?= $kefu_qq_1 ?>&Site=sc.chinaz.com&Menu=yes"><img style='width: 30px;height: 34px' src="<?= $qq_icon_1 ?>" >1号客服 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></li>
      <li><a target="_blank" href="tencent://message/?uin=<?= $kefu_qq_2 ?>&Site=sc.chinaz.com&Menu=yes"><img style='width: 30px;height: 34px' src="<?= $qq_icon_2 ?>">2号客服 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></li>
      <li><a target="_blank" href="tencent://message/?uin=<?= $kefu_qq_3 ?>&Site=sc.chinaz.com&Menu=yes"><img style='width: 30px;height: 34px' src="<?= $qq_icon_3 ?>" >3号客服 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></li>
    </ul>
    <div class="floatDtxt">免费热线电话</div>
    <div class="floatDtel">
        <span style="font-size: 14pt;color: #ee7e20;font-weight: bolder">
            <a href="tel:<?= $rxdh ?>" style="font-size: 12pt;color: #ee7e20;">
                <?= $rxdh ?>
            </a>
        </span>
    </div>
    <div class="floatImg"><img src="/images/erweima.jpg" width="100%">手机扫一扫</div>
  </div>

</div>


<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

<script type="text/javascript">
    $(document).ready(function () {
        //alert("loaded!");
            // back-to-top
        $(window).scroll(function(){
            if ($(this).scrollTop() > 500) {
                $('.back-to-top').fadeIn();
            } else {
                $('.back-to-top').fadeOut();
            }
        });
        $(".back-to-top").click(function(e) {
            e.preventDefault();
            $("html, body").animate({ scrollTop: 0 }, "slow");
        });

        //在线客服
        var flag=0;
        $('#rightArrow').on("click",function(){
            if(flag==1){
                $("#floatDivBoxs").animate({right: '-175px'},300);
                $(this).animate({right: '-5px'},300);
                $(this).css('background-position','-50px 0');
                flag=0;
            }else{
                $("#floatDivBoxs").animate({right: '0'},300);
                $(this).animate({right: '170px'},300);
                $(this).css('background-position','0px 0');
                flag=1;
            }
        });


    });


</script>
